 package cn.itlaobing.web.controller;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

import javax.servlet.http.HttpSession;

import cn.itlaobing.service.impl.BaseServiceImpl;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.itlaobing.entity.Account;
import cn.itlaobing.service.impl.AccountServiceImpl;

@Controller
public class AccountController {
	
	@Autowired
	AccountServiceImpl accountService ;

	@Autowired
	BaseServiceImpl baseServiceImpl ;

	@RequestMapping(value="/signin",method=RequestMethod.GET)
	public String login(){
		return "signIn";
		
	}

	@RequestMapping(value="/hotUpdate",method=RequestMethod.GET)
	public String index(HttpSession session, String username, String userpass) throws Exception {

		//service 可以修改
		Class clazz = accountService.getClass();
		Field field = clazz.getDeclaredField("name");
		field.setAccessible(true);
		field.set(accountService,"成功");

		//父类的可以修改，但是没法传给子类
		Class baseClazz = baseServiceImpl.getClass();
		Field baseUrlField = baseClazz.getDeclaredField("baseurl");
		baseUrlField.setAccessible(true);
		baseUrlField.set(baseServiceImpl,"www.tt.com");

		accountService.findAcc(username);

		System.out.println(baseServiceImpl.getBaseurl());

		return "signIn";
		
	}
	

}
